import xlrd
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.action_chains import ActionChains
wd = webdriver.Chrome()
file = xlrd.open_workbook("../../user1.xls")
#参数化
list= file.values.tolist()
for line in list:
    sleep(3)
    print(line)
    username = line[0]
    password = line[1]
    mail = line[2]
    wd.get("https://afterwin.cn/")
    element1 = wd.find_element_by_link_text("注册")
    element1.click()
    sleep(3)
    wd.find_element_by_id("userName").send_keys(username)
    wd.find_element_by_id("passWord").send_keys(password)
    wd.find_element_by_id("mail").send_keys(mail)
    wd.find_element_by_css_selector("button[type='submit']").click()
    #添加检查点
    expect ="恭喜您成功注册为本站会员，现在你可以参与社区讨论和分享了"
    actual =wd.find_element_by_css_selector(".container .row .alert:nth-last-child(1)").text
    print(actual)
    if expect in actual:
        print("注册成功")
    else:
        print("注册失败")
    sleep(3)
    wd.find_element_by_link_text(username).click()
    sleep(3)
    wd.find_element_by_link_text("退出").click()
    sleep(3)
file.close()
wd.quit()

